package org.theqcp.wow.sim.gui.tabs.imagethings;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

public class ImagePanel extends JPanel {

    private static final long serialVersionUID = -7014450590693093302L;

    protected Image img;

    public ImagePanel(String imgPath) {
	super();

	URL url = this.getClass().getResource("/" + imgPath);

	if( url != null ) {
	    this.img = new ImageIcon(url).getImage();
	} else {
	    this.img = new ImageIcon(imgPath).getImage();
	}

	setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

	Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
	setPreferredSize(size);
	setMinimumSize(size);
	setMaximumSize(size);
	setSize(size);
    }

    @Override
    protected void paintComponent( Graphics g ) {
	g.drawImage(img, 0, 0, null);
    }

}
